<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>医生信息修改</title>
    <link rel="stylesheet" href="layui/css/layui.css" />
</head>

<body style="padding:20px">
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>修改信息</legend>
    </fieldset>
    <form class="layui-form" action=" " lay-filter="formUpdate">
        <div class="layui-form-item">
            <label class="layui-form-label">医生编号</label>
            <div class="layui-input-block">
                <input type="text" name="doctorId" readonly="readonly" lay-verify="title" autocomplete="off"
                    placeholder="请输入标题" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">医生姓名</label>
            <div class="layui-input-block">
                <input type="text" name="doctorName" lay-verify="title" autocomplete="off" placeholder="请输入标题"
                    class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">级别</label>
            <div class="layui-input-block">
                <select class="stype" name="dp" id="dp" lay-verify="required" lay-filter="xmFilter">
                    <option value="">请选择医生级别</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">科室</label>
            <div class="layui-input-block">
                <select class="stype" name="dp1" id="dp1" lay-verify="required" lay-filter="xmFilter">
                    <option value="">请选择所属科室</option>
                </select>
            </div>
        </div>


        <div class="layui-form-item">
            <label class="layui-form-label">忙碌/空闲</label>
            <div class="layui-input-block">

                <select name="doctorState" lay-verify="title">
                    <option value="忙碌" selected>忙碌</option>
                    <option value="空闲">空闲</option>
                </select>
            </div>
        </div>


        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="submit" class="layui-btn" lay-submit="" lay-filter="submitDoc">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>

    <script type="text/javascript" src="layui/layui.js"></script>
    <script>
        layui.use(['layer', 'laydate', 'form', 'jquery'], function () {
            var layer = layui.layer;
            var laydate = layui.laydate;
            var form = layui.form;
            var $ = layui.jquery


            laydate.render({
                elem: '#date'
            });


            form.render();

            $.ajax({
                url: 'http://localhost:8080/doctype/getType',
                dataType: 'json',
                type: 'get',

                success: function (data) {
                    console.log(data),
                        $.each(data.data, function (index, value) {
                            $('#dp').append(new Option(value.doctorLevel));
                        });
                    layui.form.render("select");
                }
            })
            $.ajax({
                url: 'http://localhost:8080/doctype/getType',
                dataType: 'json',
                type: 'get',

                success: function (data) {
                    console.log(data),
                        $.each(data.data, function (index, value) {
                            $('#dp1').append(new Option(value.departmentType));
                        });
                    layui.form.render("select");
                }
            })



            form.val('formUpdate', {
                doctorId: parent.data.doctorId,
                doctorName: parent.data.doctorName,
                doctorLevel: parent.data.doctorLevel,
                doctorDepartment: parent.data.doctorDepartment,
                doctorState: parent.data.doctorState,

            });


            form.on('submit(submitDoc)', function (data) {


                $.ajax({
                    url: 'http://localhost:8080/mid/updateDoc',
                    type: 'POST',
                    dataType: 'JSON',
                    data: data.field,
                    success: function (result) {


                        var index = parent.layer.getFrameIndex(window.name);

                        parent.table.reload("Doctor");
                    }
                })



                return false;
            });
        });
    </script>
</body>

</html>